package com.basic.modules.ykf.controller;

import java.math.BigDecimal;
import java.util.*;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.basic.common.annotation.StringTrim;
import com.basic.common.exception.RRException;
import com.basic.common.utils.ParamsModel;
import com.basic.common.utils.Query;
import com.basic.common.validator.ValidatorUtils;

import com.basic.modules.sys.controller.AbstractController;
import com.basic.modules.ykf.entity.*;
import com.basic.modules.ykf.model.CommissionModel;
import com.basic.modules.ykf.model.ServiceDataModel;
import com.basic.modules.ykf.model.ToBeEnteredRsp;
import com.basic.modules.ykf.service.YkfCustomerShopService;
import com.basic.modules.ykf.service.YkfCustomerSubAccountService;
import com.basic.modules.ykf.service.YkfNotCheckRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.basic.modules.ykf.service.YkfAccountInputRecordService;
import com.basic.common.utils.PageUtils;
import com.basic.common.utils.R;


/**
 * 子账号录入记录
 *
 * @author maoheng
 * @email 15738859597@163.com
 * @date 2024-05-31 17:00:21
 */
@Slf4j
@RestController
@RequestMapping("ykf/accountInputRecord")
public class YkfAccountInputRecordController extends AbstractController {

    @Autowired
    private YkfAccountInputRecordService ykfAccountInputRecordService;

    @Autowired
    private YkfCustomerSubAccountService subAccountService;

    @Autowired
    private YkfNotCheckRecordService notCheckRecordService;

    @Autowired
    private YkfCustomerShopService shopService;

    /**
     * 店铺记录标记
     */
    @PostMapping("/editRecord")
    public R editRecord(@RequestBody YkfAccountInputRecordEntity params) {
        ykfAccountInputRecordService.editRecord(params);
        return R.ok();
    }

    /**
     * 店铺每日绩效-分页
     */
    @StringTrim
    @PostMapping("/dayPage")
    public R dayPage(@RequestBody ParamsModel<YkfAccountInputRecordEntity> params) {
        PageUtils page = ykfAccountInputRecordService.dayPage(params);
        return R.ok(page);
    }


    /**
     * 店铺整体绩效-分页
     */
    @StringTrim
    @PostMapping("/overallPage")
    public R overallPage(@RequestBody ParamsModel<YkfAccountInputRecordEntity> params) {
        PageUtils page = ykfAccountInputRecordService.overallPage(params);
        return R.ok(page);
    }


    /**
     * 接待量预警-分页
     */
    @StringTrim
    @PostMapping("/warningPage")
    public R warningPage(@RequestBody ParamsModel<YkfAccountInputRecordEntity> params) {
        PageUtils page = ykfAccountInputRecordService.warningPage(params);
        return R.ok(page);
    }


    /**
     * 客服接待汇总-分页
     */
    @StringTrim
    @PostMapping("/customerDataPage")
    public R customerDataPage(@RequestBody ParamsModel<YkfAccountInputRecordEntity> params) {
        PageUtils page = ykfAccountInputRecordService.customerDataPage(params);
        return R.ok(page);
    }


    /**
     * 客服接待汇总-分页
     */
    @StringTrim
    @PostMapping("/personalCustomerDataPage")
    public R personalCustomerDataPage(@RequestBody ParamsModel<YkfAccountInputRecordEntity> params) {
        params.getCondition().setUserId(getUserId());
        PageUtils page = ykfAccountInputRecordService.personalCustomerDataPage(params);
        return R.ok(page);
    }

    /**
     * 销售额统计表-分页
     */
    @StringTrim
    @PostMapping("/sumSalesRevenuePage")
    public R sumSalesRevenuePage(@RequestBody ParamsModel<YkfAccountInputRecordEntity> params) {
        PageUtils page = ykfAccountInputRecordService.sumSalesRevenuePage(params);
        return R.ok(page);
    }

    /**
     * 销售额统计表-分页
     */
    @StringTrim
    @PostMapping("/sumInputCountPage")
    public R sumInputCountPage(@RequestBody ParamsModel<YkfAccountInputRecordEntity> params) {
        PageUtils page = ykfAccountInputRecordService.sumInputCountPage(params);
        return R.ok(page);
    }

    /**
     * 客服考核汇总表-分页
     */
    @StringTrim
    @PostMapping("/sumCustomerPage")
    public R sumCustomerPage(@RequestBody ParamsModel<YkfAccountInputRecordEntity> params) {
        PageUtils page = ykfAccountInputRecordService.sumCustomerPage(params);
        return R.ok(page);
    }


    /**
     * 列表-分页
     */
    @StringTrim
    @PostMapping("/page")
    public R list(@RequestBody ParamsModel<YkfAccountInputRecordEntity> params) {
        PageUtils page = ykfAccountInputRecordService.queryPage(params);
        return R.ok(page);
    }


    /**
     * 待录入列表-分页
     */
    @StringTrim
    @PostMapping("/toBeEnteredPage")
    public R toBeEnteredPage(@RequestBody ParamsModel<YkfAccountInputRecordEntity> params) {
        PageUtils page = ykfAccountInputRecordService.toBeEnteredPage(params);
        return R.ok(page);
    }

    /**
     * 待录入子账号
     */
    @PostMapping("/toBeEnteredList")
    public R toBeEnteredList() {
        List<Map<String, Object>> rspMap = ykfAccountInputRecordService.toBeEnteredList();
        return R.ok(rspMap);
    }

    /**
     * 信息
     */
    @PostMapping("/info")
    public R info(@RequestBody YkfAccountInputRecordEntity params) {
        if (ObjectUtil.isEmpty(params) || ObjectUtil.isEmpty(params.getInputRecordId())) {
            throw new RRException("参数缺失");
        }
        return R.ok(ykfAccountInputRecordService.getById(params.getInputRecordId()));
    }


    /**
     * 信息
     */
    @PostMapping("/update")
    public R update(@RequestBody YkfAccountInputRecordEntity params) {
        if (ObjectUtil.isEmpty(params) || ObjectUtil.isEmpty(params.getInputRecordId())) {
            throw new RRException("参数缺失");
        }
//        YkfAccountInputRecordEntity saveData = new YkfAccountInputRecordEntity();
//        YkfCustomerSubAccountEntity subAccount = subAccountService.getById(params.getSubAccountId());
//        BeanUtil.copyProperties(subAccount, saveData);
//        saveData.setDate(params.getDate());
//        saveData.setSalesRevenue(params.getSalesRevenue());
//        saveData.setReceptionVolume(params.getReceptionVolume());
//        saveData.setConversionRate(params.getConversionRate());
//        saveData.setResponseTime(params.getResponseTime());
//        saveData.setQARatio(params.getQARatio());
//        saveData.setResponseRate(params.getResponseRate());
//        saveData.setCreateTime(DateUtil.date());
//        Long shopId = subAccount.getShopId();
//        YkfCustomerShopEntity shop = shopService.getById(shopId);
//        if (ObjectUtil.isNotEmpty(shop)) {
//            saveData.setShopNo(shop.getShopNo());
//            saveData.setCustomTypeNo(shop.getCustomTypeNo());
//            saveData.setCustomTypeName(shop.getCustomTypeName());
//            saveData.setServiceShiftNo(shop.getServiceShiftNo());
//            saveData.setServiceShiftName(shop.getServiceShiftName());
//        }
//        saveData.setInputRecordId(params.getInputRecordId());
        ykfAccountInputRecordService.updateById(params);
        return R.ok();
    }

    /**
     * 导入数据
     */
    @PostMapping("/inputData")
    public R inputData(@RequestBody YkfAccountInputRecordEntity params) {
        if (ObjectUtil.isEmpty(params) || ObjectUtil.isEmpty(params.getSubAccountId())) {
            throw new RRException("参数缺失");
        }
        QueryWrapper<YkfAccountInputRecordEntity> queryWrapper2 = new QueryWrapper<>();
        queryWrapper2.lambda().eq(YkfAccountInputRecordEntity::getSubAccountId, params.getSubAccountId())
                .eq(YkfAccountInputRecordEntity::getDate, params.getDate());
        if (ykfAccountInputRecordService.count(queryWrapper2) > 0) {
            queryWrapper2.last("limit 1");
            YkfAccountInputRecordEntity saveData = ykfAccountInputRecordService.getOne(queryWrapper2);
            //更新
            YkfCustomerSubAccountEntity subAccount = subAccountService.getById(params.getSubAccountId());
            saveData.setDate(params.getDate());
            saveData.setSalesRevenue(params.getSalesRevenue());
            saveData.setReceptionVolume(params.getReceptionVolume());
            saveData.setConversionRate(params.getConversionRate());
            saveData.setResponseTime(params.getResponseTime());
            saveData.setQARatio(params.getQARatio());
            saveData.setResponseRate(params.getResponseRate());
            saveData.setCustomField(params.getCustomField());
            Long shopId = subAccount.getShopId();
            YkfCustomerShopEntity shop = shopService.getById(shopId);
            if (ObjectUtil.isNotEmpty(shop)) {
                saveData.setShopNo(shop.getShopNo());
                saveData.setCustomTypeNo(shop.getCustomTypeNo());
                saveData.setCustomTypeName(shop.getCustomTypeName());
                saveData.setServiceShiftNo(shop.getServiceShiftNo());
                saveData.setServiceShiftName(shop.getServiceShiftName());
            }
            ykfAccountInputRecordService.updateById(saveData);
        } else {
            YkfAccountInputRecordEntity saveData = new YkfAccountInputRecordEntity();
            //新增
            YkfCustomerSubAccountEntity subAccount = subAccountService.getById(params.getSubAccountId());
            BeanUtil.copyProperties(subAccount, saveData);
            saveData.setDate(params.getDate());
            saveData.setSalesRevenue(params.getSalesRevenue());
            saveData.setReceptionVolume(params.getReceptionVolume());
            saveData.setConversionRate(params.getConversionRate());
            saveData.setResponseTime(params.getResponseTime());
            saveData.setQARatio(params.getQARatio());
            saveData.setResponseRate(params.getResponseRate());
            saveData.setCustomField(params.getCustomField());
            Long shopId = subAccount.getShopId();
            YkfCustomerShopEntity shop = shopService.getById(shopId);
            if (ObjectUtil.isNotEmpty(shop)) {
                saveData.setShopNo(shop.getShopNo());
                saveData.setCustomTypeNo(shop.getCustomTypeNo());
                saveData.setCustomTypeName(shop.getCustomTypeName());
                saveData.setServiceShiftNo(shop.getServiceShiftNo());
                saveData.setServiceShiftName(shop.getServiceShiftName());
            }

            ykfAccountInputRecordService.save(saveData);
        }
        return R.ok();
    }

    /**
     * 对外API - 导入数据
     */
    @PostMapping("/importData")
    public R importData(@RequestBody List<YkfAccountInputRecordEntity> params) {
        log.info("对外API-导入数据:" + JSONUtil.toJsonStr(params));
        if (ObjectUtil.isNotEmpty(params)) {
            List<YkfAccountInputRecordEntity> saveDataList = new ArrayList<>();
            for (YkfAccountInputRecordEntity param : params) {
                if (ObjectUtil.isEmpty(params) || ObjectUtil.isEmpty(param.getAccountNo())) {
                    continue;
                }
                YkfAccountInputRecordEntity saveData = new YkfAccountInputRecordEntity();
                QueryWrapper<YkfCustomerSubAccountEntity> queryWrapper = new QueryWrapper<>();
                if (StrUtil.isNotBlank(param.getShopName())) {
                    queryWrapper.lambda().eq(YkfCustomerSubAccountEntity::getShopName, param.getShopName());
                }
                queryWrapper.lambda().eq(YkfCustomerSubAccountEntity::getAccountNo, param.getAccountNo())
                        .isNotNull(YkfCustomerSubAccountEntity::getUserId)
                        .le(YkfCustomerSubAccountEntity::getStartDate, param.getDate())
                        .ge(YkfCustomerSubAccountEntity::getEndDate, param.getDate())
                        .last("limit 1");
                YkfCustomerSubAccountEntity subAccount = subAccountService.getOne(queryWrapper);
                if (ObjectUtil.isEmpty(subAccount)) {
                    continue;
                }
//                QueryWrapper<YkfAccountInputRecordEntity> queryWrapper2 = new QueryWrapper<>();
//                queryWrapper2.lambda().eq(YkfAccountInputRecordEntity::getSubAccountId, subAccount.getSubAccountId())
//                        .eq(YkfAccountInputRecordEntity::getDate, param.getDate());
                QueryWrapper<YkfAccountInputRecordEntity> queryWrapper2 = new QueryWrapper<>();
                queryWrapper2.lambda().eq(YkfAccountInputRecordEntity::getShopId, subAccount.getShopId())
                        .eq(YkfAccountInputRecordEntity::getAccountNo, subAccount.getAccountNo())
                        .eq(YkfAccountInputRecordEntity::getDate, param.getDate());
                if (ykfAccountInputRecordService.count(queryWrapper2) > 0) {
                    //更新
                    queryWrapper2.lambda().last("limit 1");
                    YkfAccountInputRecordEntity one = ykfAccountInputRecordService.getOne(queryWrapper2);
                    one.setDate(param.getDate());
                    one.setSalesRevenue(param.getSalesRevenue());
                    one.setReceptionVolume(param.getReceptionVolume());
                    one.setConversionRate(param.getConversionRate());
                    one.setResponseTime(param.getResponseTime());
                    one.setQARatio(param.getQARatio());
                    one.setResponseRate(param.getResponseRate());
                    one.setCreateTime(DateUtil.date());
                    ykfAccountInputRecordService.updateById(one);
                } else {
                    BeanUtil.copyProperties(subAccount, saveData);
                    saveData.setDate(param.getDate());
                    saveData.setSalesRevenue(param.getSalesRevenue());
                    saveData.setReceptionVolume(param.getReceptionVolume());
                    saveData.setConversionRate(param.getConversionRate());
                    saveData.setResponseTime(param.getResponseTime());
                    saveData.setQARatio(param.getQARatio());
                    saveData.setResponseRate(param.getResponseRate());
                    Long shopId = subAccount.getShopId();
                    YkfCustomerShopEntity shop = shopService.getById(shopId);
                    if (ObjectUtil.isNotEmpty(shop)) {
                        saveData.setShopNo(shop.getShopNo());
                        saveData.setCustomTypeNo(shop.getCustomTypeNo());
                        saveData.setCustomTypeName(shop.getCustomTypeName());
                        saveData.setServiceShiftNo(shop.getServiceShiftNo());
                        saveData.setServiceShiftName(shop.getServiceShiftName());
                    }
                    saveData.setCreateUserId(null);
                    saveData.setCreateUserName("智能爬取");
                    saveData.setCreateTime(null);
                    saveDataList.add(saveData);
                }

            }
            ykfAccountInputRecordService.saveBatch(saveDataList);
        }
        return R.ok();
    }

    /**
     * 刷新数据
     */
    @PostMapping("/refreshData")
    public R refreshData() {
        QueryWrapper<YkfAccountInputRecordEntity> queryWrapper1 = new QueryWrapper<>();
        DateTime parse = DateUtil.parse("2024-08-29");
        queryWrapper1.lambda().le(YkfAccountInputRecordEntity::getDate, parse);
        List<YkfAccountInputRecordEntity> list = ykfAccountInputRecordService.list(queryWrapper1);
        if (ObjectUtil.isNotEmpty(list)) {
            for (YkfAccountInputRecordEntity recordEntity : list) {
                String accountNo = recordEntity.getAccountNo();
                YkfAccountInputRecordEntity saveData = new YkfAccountInputRecordEntity();
                QueryWrapper<YkfCustomerSubAccountEntity> queryWrapper = new QueryWrapper<>();
                queryWrapper.lambda().eq(YkfCustomerSubAccountEntity::getAccountNo, accountNo)
                        .le(YkfCustomerSubAccountEntity::getStartDate, recordEntity.getDate())
                        .ge(YkfCustomerSubAccountEntity::getEndDate, recordEntity.getDate())
                        .last("limit 1");
                YkfCustomerSubAccountEntity subAccount = subAccountService.getOne(queryWrapper);
                if (ObjectUtil.isEmpty(subAccount)) {
                    continue;
                }
                BeanUtil.copyProperties(subAccount, saveData);
                saveData.setDate(recordEntity.getDate());
                saveData.setSalesRevenue(recordEntity.getSalesRevenue());
                saveData.setReceptionVolume(recordEntity.getReceptionVolume());
                saveData.setConversionRate(recordEntity.getConversionRate());
                saveData.setResponseTime(recordEntity.getResponseTime());
                saveData.setQARatio(recordEntity.getQARatio());
                saveData.setResponseRate(recordEntity.getResponseRate());
                Long shopId = subAccount.getShopId();
                YkfCustomerShopEntity shop = shopService.getById(shopId);
                if (ObjectUtil.isNotEmpty(shop)) {
                    saveData.setShopNo(shop.getShopNo());
                    saveData.setCustomTypeNo(shop.getCustomTypeNo());
                    saveData.setCustomTypeName(shop.getCustomTypeName());
                    saveData.setServiceShiftNo(shop.getServiceShiftNo());
                    saveData.setServiceShiftName(shop.getServiceShiftName());
                }
                saveData.setInputRecordId(recordEntity.getInputRecordId());
                ykfAccountInputRecordService.updateById(saveData);
            }
        }
        return R.ok();
    }

    /**
     * 当天不检测
     */
    @PostMapping("/dateNotCheck")
    public R dateNotCheck(@RequestBody YkfAccountInputRecordEntity params) {
        if (ObjectUtil.isEmpty(params) || ObjectUtil.isEmpty(params.getSubAccountId())) {
            throw new RRException("参数缺失");
        }
        if (ObjectUtil.isNotEmpty(params.getStartDate()) && ObjectUtil.isNotEmpty(params.getEndDate())) {
            List<YkfNotCheckRecordEntity> saveDataList = new ArrayList<>();
            Date startDate = params.getStartDate();
            Date endDate = params.getEndDate();
            while (startDate.compareTo(endDate) <= 0) {
                YkfNotCheckRecordEntity saveData = new YkfNotCheckRecordEntity();
                YkfCustomerSubAccountEntity subAccount = subAccountService.getById(params.getSubAccountId());
                BeanUtil.copyProperties(subAccount, saveData);
                saveData.setType(1);
                saveData.setDate(startDate);
                Long shopId = subAccount.getShopId();
                YkfCustomerShopEntity shop = shopService.getById(shopId);
                if (ObjectUtil.isNotEmpty(shop)) {
                    saveData.setShopNo(shop.getShopNo());
                    saveData.setPlatformNo(shop.getPlatformNo());
                    saveData.setPlatformName(shop.getPlatformName());
                }
                saveDataList.add(saveData);
                startDate = DateUtil.offsetDay(startDate, 1);
            }
            notCheckRecordService.saveBatch(saveDataList);
        } else {
            YkfNotCheckRecordEntity saveData = new YkfNotCheckRecordEntity();
            YkfCustomerSubAccountEntity subAccount = subAccountService.getById(params.getSubAccountId());
            BeanUtil.copyProperties(subAccount, saveData);
            saveData.setType(1);
            saveData.setDate(params.getDate());
            Long shopId = subAccount.getShopId();
            YkfCustomerShopEntity shop = shopService.getById(shopId);
            if (ObjectUtil.isNotEmpty(shop)) {
                saveData.setShopNo(shop.getShopNo());
                saveData.setPlatformNo(shop.getPlatformNo());
                saveData.setPlatformName(shop.getPlatformName());
            }
            notCheckRecordService.save(saveData);
        }

        return R.ok();
    }

    /**
     * 永远不检测
     */
    @PostMapping("/foreverNotCheck")
    public R foreverNotCheck(@RequestBody YkfAccountInputRecordEntity params) {
        if (ObjectUtil.isEmpty(params) || ObjectUtil.isEmpty(params.getSubAccountId())) {
            throw new RRException("参数缺失");
        }
        YkfNotCheckRecordEntity saveData = new YkfNotCheckRecordEntity();
        YkfCustomerSubAccountEntity subAccount = subAccountService.getById(params.getSubAccountId());
        BeanUtil.copyProperties(subAccount, saveData);
        saveData.setType(2);
        notCheckRecordService.save(saveData);
        return R.ok();
    }

    /**
     * 不检测列表-分页
     */
    @StringTrim
    @PostMapping("/notCheckPage")
    public R notCheckPage(@RequestBody ParamsModel<YkfNotCheckRecordEntity> params) {
        if (ObjectUtil.isEmpty(params) || ObjectUtil.isEmpty(params.getCondition()) || ObjectUtil.isEmpty(params.getCondition().getType())) {
            throw new RRException("参数缺失");
        }
        if (params.getCondition().getType() == 2) {
            params.getCondition().setDateStart(null);
            params.getCondition().setDateEnd(null);
        }
        PageUtils page = notCheckRecordService.queryPage(params);
        return R.ok(page);
    }

    /**
     * 取消不检测
     */
    @PostMapping("/cancelNotCheck")
    public R cancelNotCheck(@RequestBody YkfNotCheckRecordEntity params) {
        if (ObjectUtil.isEmpty(params) || ObjectUtil.isEmpty(params.getNotCheckRecordId())) {
            throw new RRException("参数缺失");
        }
        notCheckRecordService.removeById(params.getNotCheckRecordId());
        return R.ok();
    }

    /**
     * 我的店铺
     */
    @StringTrim
    @PostMapping("/personalShopPage")
    public R personalShopPage(@RequestBody ParamsModel<YkfCustomerSubAccountEntity> params) {
        params.getCondition().setUserId(getUserId());
        PageUtils page = subAccountService.personalShopPage(params);
        return R.ok(page);
    }

    /**
     * 我的店铺
     */
    @StringTrim
    @PostMapping("/confirmSubAccount")
    public R confirmSubAccount(@RequestBody YkfCustomerSubAccountEntity subAccount) {
        subAccountService.confirmSubAccount(subAccount);
        return R.ok();
    }

    /**
     * 我的服务数据
     */
    @StringTrim
    @PostMapping("/personalServiceDataPage")
    public R personalServiceDataPage(@RequestBody ParamsModel<YkfAccountInputRecordEntity> params) {
        params.getCondition().setUserId(getUserId());
        PageUtils page = ykfAccountInputRecordService.personalServiceDataPage(params);
        return R.ok(page);
    }


    /**
     * 我的提成核对表
     */
    @PostMapping("/personalCommissionCheckPage")
    public R personalCommissionCheckPage(@RequestBody YkfAccountInputRecordEntity condition) {
        if (ObjectUtil.isEmpty(condition) || ObjectUtil.isEmpty(condition.getMonth())) {
            throw new RRException("参数缺失");
        }
        condition.setUserId(getUserId());
        List<CommissionModel> list = ykfAccountInputRecordService.personalCommissionCheckPage(condition);
        return R.ok(list);
    }

    /**
     * 客服提成核对表
     */
    @PostMapping("/commissionCheckPage")
    public R commissionCheckPage(@RequestBody YkfAccountInputRecordEntity condition) {
        if (ObjectUtil.isEmpty(condition) || ObjectUtil.isEmpty(condition.getMonth())) {
            throw new RRException("参数缺失");
        }
        Map<String, Object> list = ykfAccountInputRecordService.commissionCheckPage3(condition);
        return R.ok(list);
    }

    /**
     * 客服提成核对汇总表
     */
    @PostMapping("/sumCommissionCheckPage")
    public R sumCommissionCheckPage(@RequestBody YkfAccountInputRecordEntity condition) {
        if (ObjectUtil.isEmpty(condition) || ObjectUtil.isEmpty(condition.getMonth())) {
            throw new RRException("参数缺失");
        }
        List<CommissionModel> list = ykfAccountInputRecordService.sumCommissionCheckPage(condition);
        Map<String, BigDecimal> sumInfo = new HashMap<>();
        BigDecimal sumSalesRevenue = BigDecimal.ZERO;
        BigDecimal sumCommissionSalary = BigDecimal.ZERO;
        if (ObjectUtil.isNotEmpty(list)) {
            for (CommissionModel model : list) {
                sumSalesRevenue = sumSalesRevenue.add(model.getMonthSalary());
                sumCommissionSalary = sumCommissionSalary.add(ObjectUtil.isEmpty(model.getCommissionSalary()) ? BigDecimal.ZERO : model.getCommissionSalary());
            }
        }
        sumInfo.put("sumSalesRevenue", sumSalesRevenue);
        sumInfo.put("sumCommissionSalary", sumCommissionSalary);
        return R.ok(list).put("sumInfo", sumInfo);
    }

    /**
     * 服务数据
     */
    @PostMapping("/serviceData")
    public R serviceData(@RequestBody ServiceDataModel serviceData) {
        List<ServiceDataModel> list = ykfAccountInputRecordService.serviceData(serviceData);
        return R.ok(list);
    }

}
